package com.example.smartcity.ui.guide;

import androidx.appcompat.app.AppCompatActivity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.smartcity.R;
import com.example.smartcity.ui.Tools.File;

public class SetPort extends AppCompatActivity {

    private TextView TV_save;
    private EditText ET_setPort;
    private SharedPreferences sharedPreferences;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set_port);
        TV_save = findViewById(R.id.TV_save);
        ET_setPort = findViewById(R.id.ET_setPort);
        savePort();
    }
    public void setBack(View view){
        this.finish();
    }

    public void savePort(){
        TV_save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new File(SetPort.this).saveFile("IP",ET_setPort.getText().toString());
                if (new File(SetPort.this).readFile("IP").equals(ET_setPort.getText().toString())){
                    Toast.makeText(SetPort.this, "保存成功", Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(SetPort.this, "保存失败", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}